from django.db import models
from dingxiang.utils.models import BaseModel

# Create your models here.

# 生活手册方向
class LifeHandbookDirection(models.Model):
    name = models.CharField(max_length=100, null=True, blank=True, verbose_name='生活手册方向')
    class Meta:
        db_table = 'lifeHandbook_direction'
        verbose_name_plural = '生活手册方向'

    def __str__(self):
        return self.name

# 生活手册分类
class LifeHandbookClassification(models.Model):
    name = models.CharField(max_length=100, verbose_name='生活手册分类')
    handbook_direction = models.ManyToManyField(LifeHandbookDirection, null=True, blank=True, verbose_name="生活手册方向")
    class Meta:
        db_table = 'lifeHandbook_classification'
        verbose_name_plural = '生活手册分类'

    def __str__(self):
        return self.name

# 生活手册文章内容
class LifeHandbookArticlesContent(models.Model):
    # 手册标题
    manual_title = models.CharField(max_length=100, null=True, blank=True, verbose_name='手册标题')
    # 发表日期
    manual_Time = models.DateField(auto_now_add=True, null=True, blank=True, verbose_name='发表日期')
    # 手册作者
    manual_author = models.CharField(max_length=100, null=True, blank=True, verbose_name='手册作者')
    # 手册图片
    manual_images = models.ImageField(upload_to='life_handbook/', null=True, blank=True, verbose_name='手册图片')
    # 手册内容
    manual_content = models.TextField(verbose_name='手册内容', null=True, blank=True)
    handbook_articles = models.ForeignKey(LifeHandbookClassification, null=True, blank=True, on_delete=models.CASCADE, verbose_name="生活手册分类")
    class Meta:
        db_table = 'lifeHandbook_articles_content'
        verbose_name_plural = '生活手册文章内容'

    def __str__(self):
        return self.manual_title